import * as path from 'node:path';
import { fileURLToPath, URL } from 'node:url';

export default class PathHelper {
  static relativeToRoot = '../';

  static getPathAtRoot = () => {
    return fileURLToPath(new URL(PathHelper.relativeToRoot, import.meta.url));
  };

  /**
   * 通过相对 root 的路径获得绝对路径。root 目录指 /app/。
   *
   * @param relativePath 相对 root 的路径
   */
  static getPathRelativeToRoot = (relativePath: string) => {
    return path.resolve(PathHelper.getPathAtRoot(), relativePath);
  };
}
